//
//  GLTollStationSectionHeaderView.m
//  Runone
//
//  Created by ekkaLyn on 2017/4/20.
//  Copyright © 2017年 runone. All rights reserved.
//

#import "GLTollStationSectionHeaderView.h"
#import "EKPopMenuView.h"
#import "Masonry.h"
#import "UIView+Addition.h"
#import "AppConstants.h"
#import "EKPopMenuView.h"
#import "NSDate+Extension.h"
#import "NSString+Addition.h"
#import "CJUseTime.h"
#import "CommonUtilityjudge.h"

#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define kBtnLayerColor  RGBCOLOR(196, 197, 198)
@interface  GLTollStationSectionHeaderView ()

@property (nonatomic, strong)UILabel  *totalChargeTitleL;
@property (nonatomic, strong)UILabel  *totalChargeL;
@property (nonatomic, strong)UILabel  *exportTotalTrafficFlowTitleL;
@property (nonatomic, strong)UILabel  *exportTotalTrafficFlowL;
@property (nonatomic, strong)UIView   *bottomLineView;
@property (nonatomic, strong)UIView   *verticalLineView;

@property (nonatomic, strong) NSMutableArray *calendaerArray; // 日历数组


@end

@implementation GLTollStationSectionHeaderView

#pragma   ------收费数据界面

- (instancetype)initGLStationSectionView:(CGRect)sectionFrame  {
    
    if (self = [super initWithFrame:sectionFrame]) {
        self.backgroundColor = [UIColor whiteColor];
        [self setUp];
        [self layoutUI];
        _calendaerArray = [[NSMutableArray alloc] init];
        [self getCalendarDataArray];
    }
    return self;
}

//设置UI界面
- (void) setUp {
    //    NSDate *nowDate = [NSDate date];
    //    NSString *nowDateStr = [[CJUseTime sharedInstance] dataToString:nowDate];
    _calendaerBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    //    [_calendaerBtn setTitle:nowDateStr forState:UIControlStateNormal];
    _calendaerBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    [_calendaerBtn setBackgroundColor:RGBCOLOR(89, 187, 222)];
    [_calendaerBtn setTitleColor:kTextColor forState:UIControlStateNormal
     ];
    _calendaerBtn.layer.cornerRadius = 2.0;
    [_calendaerBtn addTarget:self action:@selector(calendarBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_calendaerBtn];
    
    _totalChargeTitleL = [[UILabel alloc] init];
    _totalChargeTitleL.font = [UIFont systemFontOfSize:14];
    _totalChargeTitleL.textColor = kTextColor;
    _totalChargeTitleL.text      = @"收费总金额:";
    _totalChargeTitleL.textAlignment = NSTextAlignmentRight;
    [self addSubview:_totalChargeTitleL];
    
    _totalChargeL = [[UILabel alloc] init];
    _totalChargeL.font = [UIFont systemFontOfSize:14];
    _totalChargeL.textColor  = [UIColor blackColor];
    //_totalChargeL.text = @"12345678.00元";
    [self addSubview:_totalChargeL];
    
    _exportTotalTrafficFlowTitleL = [[UILabel alloc] init];
    _exportTotalTrafficFlowTitleL.font = [UIFont systemFontOfSize:14];
    _exportTotalTrafficFlowTitleL.textColor = kTextColor;
    _exportTotalTrafficFlowTitleL.text      = @"出口总车流量:";
    _exportTotalTrafficFlowTitleL.textAlignment = NSTextAlignmentRight;
    [self addSubview:_exportTotalTrafficFlowTitleL];
    
    _exportTotalTrafficFlowL = [[UILabel alloc] init];
    _exportTotalTrafficFlowL.font = [UIFont systemFontOfSize:14];
    _exportTotalTrafficFlowL.textColor = [UIColor blackColor];
    // _exportTotalTrafficFlowL.text   = @"987654321.00车次";
    [self addSubview:_exportTotalTrafficFlowL];
    
    _bottomLineView = [[UIView alloc] init];
    _bottomLineView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:_bottomLineView];
    
    _verticalLineView = [[UIView alloc] init];
    _verticalLineView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:_verticalLineView];
}

//屏幕适配
- (void) layoutUI {
    __weak __typeof(self)weakSelf = self;
    [_calendaerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf).with.offset(8);
        make.top.equalTo(weakSelf).with.offset(4);
        make.bottom.equalTo(weakSelf).with.offset(-4);
        make.width.mas_equalTo(weakSelf.width * 2 / 5);
    }];
    
    if (iPhone5) {
        [_totalChargeTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.verticalLineView.mas_right);
            make.top.equalTo(weakSelf).with.offset(4);
            make.width.mas_equalTo(90);
            make.height.mas_equalTo(20);
        }];
    }else {
        [_totalChargeTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(weakSelf.verticalLineView.mas_right).with.offset(4);
            make.top.equalTo(weakSelf).with.offset(4);
            make.width.mas_equalTo(90);
            make.height.mas_equalTo(20);
             }];
    }
   
    
    [_totalChargeL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.totalChargeTitleL.mas_right);
        make.top.equalTo(weakSelf).with.offset(4);
        make.height.mas_equalTo(20);
    }];
    
    [_exportTotalTrafficFlowTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.totalChargeTitleL.mas_left);
        make.bottom.equalTo(weakSelf.mas_bottom).with.offset(-4);
        make.width.mas_equalTo(90);
        make.height.mas_equalTo(20);
    }];
    
    [_exportTotalTrafficFlowL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.totalChargeL.mas_left);
        make.bottom.mas_equalTo(weakSelf.mas_bottom).with.offset(-4);
        make.height.mas_equalTo(20);
    }];
    
    [_bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(weakSelf);
        make.height.mas_equalTo(1);
    }];
    
    [_verticalLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf).with.offset(3);
        make.bottom.equalTo(weakSelf).with.offset(-3);
        make.width.mas_equalTo(1);
        make.left.equalTo(weakSelf.calendaerBtn.mas_right).with.offset(8);
    }];
}

- (void)getCalendarDataArray {
    
}
//选择时间选择器确定
- (void) setIsSelectCanderBtn:(BOOL)isSelectCanderBtn {
 _isSelectCanderBtn = isSelectCanderBtn;
}

//时间选择按钮点击
- (void) calendarBtnClick:(UIButton *)sender {
    
    _isSelectCanderBtn = !_isSelectCanderBtn;
    if (self.btnClickBlock) {
        self.btnClickBlock(_isSelectCanderBtn);
    }
    
}
#pragma mark -刷新数据
- (void)refreshBtnTitleString:(NSString *)titlStr {
    [self.calendaerBtn setTitle:titlStr forState:UIControlStateNormal];
}

- (void) refreshChargeLabelText:(NSString *)chargeStr vehicleFlow:(NSString *)flowStr{
    
    self.totalChargeL.text = chargeStr;
    self.exportTotalTrafficFlowL.text = flowStr;
    
    
    
    
}


@end
